package com.diligent.cloud.sfc.service;

import com.canny.commons.model.ObjectResult;
import org.quartz.JobExecutionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;

/**
 * InsertService class
 *
 * @author xf107278
 * @date 2/26/2020
 */
@Component
public class ObtainTokenService extends QuartzJobBean {
    @Value("${soa.url}")
    private String soaRequestUrl;

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private RestTemplate restTemplate;

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) {
        try {
            String requestUrl = String.format(soaRequestUrl + "get_eline_name/%s", "at.38s4iyczacw2eet7b3beevbgl912t0pz1-2rsetdrwx6-1xeqgcb-fvpvhhoev");
            ObjectResult result = restTemplate.getForObject(requestUrl, ObjectResult.class);
        }catch (HttpClientErrorException httpClientErrorException){
            logger.error("token验证失败");
        }


    }

}
